<template>
    <section>
        <!--输入查询-->
        <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
            <el-form :inline="true" :model="filters">
                <el-form-item>
                    <el-input v-model="filters.name" placeholder="姓名"></el-input>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="getTestList">查询</el-button>
                </el-form-item>
            </el-form>
        </el-col>
        <div class="img_box">
            <ul v-loading="loading">
                <li v-for="(item,index) in list" :key="index">
                    <div class="img">
                        <img :src="item.thumbnail_pic_s"/>
                    </div>
                    <div class="content">
                        <p>{{item.name}}</p>
                        <p>{{item.title}}</p>
                    </div>
                </li>
            </ul>
            <!--分页-->
        </div>
        <el-col :span="24" class="toolbar">
            <el-pagination layout="prev, pager, next" @current-change="handleCurrentChange" :page-size="15"
                           :total="total" style="float:right;">
            </el-pagination>
        </el-col>
    </section>
</template>
<script>
    import {getMyTestPage} from "../../api/api";

    export default {
        data() {
            return {
                loading: false,
                filters: { // 查询时的字段
                    name: ''
                },
                total: 0, // 总数
                page: 1, // 页数（第一页）
                list: [] // 获取的接口数据
            }
        },
        methods: {
            // 分页点击事件
            handleCurrentChange(val) {
                this.page = val;
                this.getTestList();
            },
            getTestList() {
                let data = {
                    page: this.page,
                    name: this.filters.name
                }
                this.loading = true
                getMyTestPage(data).then(res => {
                    if (res.status === 200) {
                        this.total = res.data.total
                        this.list = res.data.datas
                        this.loading = false
                        // console.log(res.data.total)
                    }
                })
            }
        },
        mounted() {
            this.getTestList()
        }
    }
</script>
<style lang="scss">
    .img_box {
        width: 100%;
        ul {
            width: 100%;
            list-style: none;
            margin: 0;
            padding: 0;
            li {
                width: 99%;
                display: inline-flex;
                align-items: center;
                border-bottom: 1px solid #f2f2f2;
                padding: 10px;
                .img {
                    width: 70px;
                    height: 70px;
                    border: 1px solid #f2f2f2;
                    border-radius: 5px;
                    display: inline-flex;
                    align-items: center;
                    justify-content: center;
                    padding: 5px;
                    img {
                        width: 50px;
                        height: 50px;
                    }
                }
                .content {
                    p {
                        padding-left: 10px;
                    }
                    p:first-child {
                        font-size: 15px;
                        color: #5e7382;
                    }
                    p:last-child {
                        font-size: 18px;
                        color: #666;
                    }
                }
            }
        }
    }
</style>
